#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using tl = tuple < int, int, int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2510;

int h, w, lefl, lefc, fa[N << 1];
char s[N][N];
set < int > G[N << 1];
vector < tl > al;

int gf(int x) { return x == fa[x] ? x : fa[x] = gf(fa[x]); }

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	h = in, w = in; lefl = h; lefc = w;
	rep(i, 1, h + w) fa[i] = i;
	rep(i, 1, h) {
		scanf("%s", s[i] + 1);
		rep(j, 1, w) if(s[i][j] == 'R') {
			if(gf(i) == gf(j + h)) continue;
			G[i].ep(j + h); G[j + h].ep(i); fa[gf(i)] = gf(j + h); 
		}
	}
	while(true) {
		int px = -1, py = -1;
		rep(i, 1, h + w) {
			if(G[i].size() != 1) continue;
			int v = *G[i].begin();
			if(G[v].size() != 1) {
				px = i, py = v; continue;
			}
		}
		if(px == -1) break;
		if(px <= h) { al.eb(0, px, py - h); lefl--; }
		else { al.eb(1, py, px - h); lefc--; }
		G[px].erase(py); G[py].erase(px);
	}
	rep(i, 1, h) {
		if(G[i].size() == 0) continue;
		int v = *G[i].begin() - h;
		if(lefl > lefc) al.eb(1, i, v), lefc--;
		else al.eb(0, i, v), lefl--;
	}
	printf("%lu\n", al.size());
	for(auto v : al) {
		int op, x, y; tie(op, x, y) = v;
		printf("%c %d %d\n", op ? 'Y' : 'X', x, y);
	}
	return 0;
}
